package com.jia.blog.controller;


import com.jia.blog.common.lang.R;
import com.jia.blog.entity.VideoType;
import com.jia.blog.entity.vo.VideoTypeVo;
import com.jia.blog.service.VideoTypeService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jiajia
 * @since 2020-12-05
 */
@RestController
@RequestMapping("/video-type")
@Api(tags = "视频分类管理")
public class VideoTypeController {

    @Autowired
    VideoTypeService videoTypeService;

    @GetMapping("queryPageList")
    public R queryPageList(VideoTypeVo videoTypeVo) {
        Map<String,Object> map = videoTypeService.queryPageList(videoTypeVo);
        return R.ok().data(map);
    }

    @GetMapping("/list")
    public R list() {
        List<VideoType> list = videoTypeService.list();
        return R.ok().data("data",list);
    }
    @PostMapping("/save")
    public R save(@RequestBody VideoType videoType) {
        videoTypeService.save(videoType);
        return R.ok();
    }

    @PutMapping("/update")
    public R update(@RequestBody VideoType videoType) {
        videoTypeService.updateById(videoType);
        return R.ok();
    }
    
    @DeleteMapping("delete/{id}")
    public R delete(@PathVariable("id") Long id){
        videoTypeService.removeById(id);
        return R.ok();
    }
    
}
